<?php
ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';
ini_set('memory_limit', '512M');


$packType = $argv[1] ?? null ;

var_dump(['packType'=>$packType]);

if(!$packType){
    echo "pack_type required".PHP_EOL;
    exit;
}

if( !($packType > 0 && $packType < 9) ){
    echo "pack_type error".PHP_EOL;
    exit;
}

$where['pack_type[>=]']  = \Biz\model\brand\BrandPackage::NEW_PACK_TYPE_START;

$brands = \Biz\model\brand\Brand::select('*', $where);

$data['pack_type'] = $packType;

foreach ($brands as $brand){
    $where['id'] = $brand['id'];
    $ret = \Biz\model\brand\Brand::update($data,$where);
    if ($ret->errorCode() !== '00000') {
        echo "品牌ID:{$brand['id']} pack_type [ {$brand['pack_type']} -> $packType ] set fail!".PHP_EOL;
    }
    echo "品牌ID:{$brand['id']} pack_type [ {$brand['pack_type']} -> $packType ] set success".PHP_EOL;
}

echo "finish".PHP_EOL;

exit(0);

